<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <%@ include file="../system/admin/top.jsp" %>
    <!-- jsp文件头和头部 -->
    <script src='static/js/jquery-1.9.1.min.js'></script>
    <script type="text/javascript" src="static/js/myjs/head.js${getTime}"></script>
    <script type="text/javascript" src="static/js/layer.js"></script>
    <link rel="stylesheet" href="static/css/layui.css" media="all">
    <script src='static/js/commonJs.js${getTime}'></script>
    <script type="text/javascript" src="static/js/jquery.tips.js"></script>
    <link href="static/sweetalert/sweetalert.css" rel="stylesheet" />
    <script src='static/sweetalert/sweetalert.min.js'></script>
    <style>
        .divcss5 {
            width: 100px;
            height: 20px;
        }
    </style>
    <script>
        $(top.hangge());

        //批量审核
        function manyPass2017() {
            layerOpen();
        }

    </script>
</head>
</head>
<body>

<form action="<%=basePath%>blackName/blackNameList.do" method="post" name="pageForm" id="pageForm">
    <div style="border: 0px solid darkgray;padding: 6px; ">
        <table>
            <div class="pull-left search " style="test-align: center;margin-left:20px;margin-top:20px">
                <label class="input-group-addon">借款产品：</label>
            </div>
            <div class="pull-left search" style="margin-left:10px;">
                <select id="productSource" name="productSource"
                        style="width: 100px;height:30px;margin-top:15px" >
                    <option value="">不限</option>
                    <option value="2"
                            <c:if test="${pd.productSource=='2'}">selected</c:if> psId="182180001">今日现金
                    </option>
                    <option value="6"
                            <c:if test="${pd.productSource=='6'}">selected</c:if> psId="186180001">卡贷
                    </option>
                    <option value="39"
                            <c:if test="${'39' eq pd.productSource}">selected</c:if> psId="1839180001">融360
                    </option>
                    <option value="41"
                            <c:if test="${'41' eq pd.productSource}">selected</c:if> psId="1841180001">消费分期
                    </option>
                    <option value="43"
                            <c:if test="${'43' eq pd.productSource}">selected</c:if> psId="1843180001">游戏贷
                    </option>
                    <option value="8"
                            <c:if test="${'8' eq pd.productSource}">selected</c:if> psId="188180001">教育分期
                    </option>
                    <option value="45"
                            <c:if test="${'45' eq pd.productSource}">selected</c:if> psId="1839180002">
                        游戏贷融360
                    </option>
                </select>
            </div>
            <div class="pull-left search " style="test-align: center;margin-left:20px;margin-top:20px">
                <label class="input-group-addon">催收员：</label>
            </div>
            <div class="pull-left search" style="margin-left:10px;margin-top:15px">
                <input style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" type="text" class="form-control"
                       name="callUser" id="callUser" value="${pd.callUser}"/>
            </div>
            <hr style="height:0px;border:none;border-top:0px groove ghostwhite;">
            <div class="pull-left search " style="test-align: center;margin-left:20px;margin-top:5px">
                <label class="input-group-addon">自定义项：</label>
            </div>
            <div class="pull-left search" style="margin-left:5px;">
                <input style="width:100px;height:20px" type="text" class="form-control"
                       name="telephone" id="telephone" placeholder="手机号（本人）" value="${pd.telephone }"/>
                <input style="width:100px;height:20px" type="text" class="form-control"
                       name="contIdCard" id="contIdCard" placeholder="借款人身份证号" value="${pd.contIdCard}"/>
                <input style="width:100px;height:20px" type="text" class="form-control"
                       name="realName" id="realName" placeholder="借款人姓名" value="${pd.realName}"/>
                <input style="width:100px;height:20px" type="text" class="form-control"
                       name="callLoanNid" id="callLoanNid" placeholder="催收编号" value="${pd.callLoanNid}"/>
            </div>
            <br><br>
            <div style="margin-left:20px;margin-top:20px" width="30%">
                <button id="chaxun" class="btn btn-primary btn-small" onclick="chaxun()">查询</button>
                <input type="button" id="manyPass" value="批量审批" class="btn btn-primary btn-small"
                       onclick="manyPass2017();"></button>
            </div>
        </table>

        <table class="table table-striped table-bordered table-hover" style="margin-left: 20px;margin-top: 20px;"
               width="1700px">
            <thead>
            <tr>
                <th width="2%" align="center"><input id="quanxuan" type="checkbox" name="checkAll"
                                                     style="position:relative;opacity:100;"></th>
                <th width="7%">催收编号</th>
                <th width="7%">借款人姓名</th>
                <!-- <th width="7%">借款人身份证号</th>
                <th width="7%">手机号</th> -->
                <th width="7%">借款产品名称</th>
                <th width="7%">催收结果</th>
                <th width="7%">提交时间</th>
                <th width="7%">拉黑理由</th>
                <th width="7%">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:choose>
                <c:when test="${not empty pageList}">
                    <c:forEach items="${pageList}" var="var" varStatus="vs">
                        <tr>
                            <td align="center"><input id="${var.id}"
                                                      value="${var.id}" idCard='${var.cont_id_card}'
                                                      productSource='${var.product_source}' name="subBox"
                                                      type="checkbox"
                                                      style="position:relative;opacity:100;">
                            </td>
                            <td><%--<a href="javascript:void(-1);" style="color: blue"
                                   onclick="toDetail('${var.call_loan_nid}','${var.user_id}','${var.repayment_id}')">${var.call_loan_nid}</a>--%>
                                <a href="javascript:void(0)" onclick="$.tiaozhuan(this,'${var.call_loan_nid}','${var.user_id}','${var.repayment_id}','${var.real_name}','')"
                                   style="color: blue">
                                        ${var.call_loan_nid}
                                </a>
                            </td>
                            <td>${var.real_name}</td><!-- 借款人姓名-->
                            <%-- <td>${var.cont_id_card}</td><!-- 借款人身份证号-->
                            <td>${var.telephone}</td><!-- 手机号--> --%>
                            <td>${var.borrow_name}</td><!-- 借款产品名称-->
                            <td>
                            	<c:if test="${var.call_result == '0'}">已还清</c:if>
                            	<c:if test="${var.call_result == '1'}">承诺还款</c:if>
                            	<c:if test="${var.call_result == '2'}">投诉/死亡</c:if>
                            	<c:if test="${var.call_result == '3'}">失联</c:if>
                            	<c:if test="${var.call_result == '4'}">查找中</c:if>
                            	<c:if test="${var.call_result == '5'}">跳票</c:if>
                            	<c:if test="${var.call_result == '6'}">新案件</c:if>
                            	<c:if test="${var.call_result == '7'}">暂停催收</c:if>
                            	<c:if test="${var.call_result == '8'}">停关机空号</c:if>
                            	<c:if test="${var.call_result == '9'}">空号</c:if>
                            	<c:if test="${var.call_result == '10'}">沟通中</c:if>
                            	<c:if test="${var.call_result == '11'}">诚意还款</c:if>
                            	<c:if test="${var.call_result == '12'}">无诚意还款</c:if>
                            	<c:if test="${var.call_result == '13'}">转告</c:if>
                            	<c:if test="${var.call_result == '14'}">尝试转告</c:if>
                            	<c:if test="${var.call_result == '15'}">无人接</c:if>
                            	<c:if test="${var.call_result == '16'}">设置拒接</c:if>
                            	<c:if test="${var.call_result == '17'}">不认识客户</c:if>
                            </td><!-- 催收结果-->
                            <td>
                            	<fmt:formatDate value="${var.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/>
                            </td><!-- 提交时间-->
                            <td>
                                <a title='${var.remark}' style="cursor: pointer;">
                                    <c:if test="${fn:length(var.remark) >= 8 }">
                                        ${fn:substring(var.remark,0,8)}...
                                    </c:if>
                                    <c:if test="${fn:length(var.remark) < 8 }">
                                        ${var.remark}
                                    </c:if>
                                </a>
                            </td><!-- 拉黑理由-->
                            <div>
                                <td>
                                    <a class='btn btn-mini btn-info'
                                       onclick="passBtn('1','${var.id}','${var.cont_id_card}','${var.product_source}');">通过</a>|
                                    <a class='btn btn-mini btn-info'
                                       onclick="passBtn('2','${var.id}','${var.cont_id_card}','${var.product_source}');">拒绝</a>
                                </td>
                            </div><!-- 操作-->
                        </tr>
                    </c:forEach>
                </c:when>
            </c:choose>

            </tbody>
        </table>

        <div class="page-header position-relative">
            <table style="width: 100%;">
                <tr>
                    <td style="vertical-align: top;">
                        <div class="pagination"
                             style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>
<script>

    function chaxun() {
        $("#pageForm").submit();
    }

    // 全选/复选
    $(function () {
        $("input[placeholder]").css({
            "font-size": "14px", "padding": "4px 6px", "color": "#000", "width": "100px"
        });
        $("#quanxuan").click(function () {
            $('input[name="subBox"]').prop("checked", this.checked);
        });
        var $subBox = $("input[name='subBox']");
        $subBox
            .click(function () {
                $("#checkAll")
                    .prop(
                        "checked",
                        $subBox.length == $("input[name='subBox']:checked").length ? true
                            : false);
            });
    });

    //批量审核
    function layerOpen() {
        var arrChk = $("input[name='subBox']:checked");
        var fenpais = [];
        var fenpaiId = new Array();
        var productSource = new Array();
        (arrChk).each(function () { //each() 遍历函数
            fenpais.push(this.id);
            fenpaiId.push($(this).attr("idCard"));
            productSource.push($(this).attr("productSource"));
        });
        if(fenpaiId == 0){
        	sweetAlert("请选择需要审核的黑名单案件！");
        	return;
        }
        console.log(fenpaiId);
        layer.confirm(
            '请选择以下审核结果：',
            {
                title: "黑名单审核",
                btn: ['审核通过', '审核拒绝', '取消'], //可以无限个按钮
                btnAlign: 'c'
                , btn3: function (index, layero) {
                layer.closeAll();
            }
            },
            function (index, layero) {//审核通过
                window.location = "blackName/checkStatusList.do?status=" + '1' + "&ids=" + fenpais + "&contIdCards=" + fenpaiId + "&productSourceB=" + productSource;

            },
            function (index) {
                window.location = "blackName/checkStatusList.do?status=" + '2' + "&ids=" + fenpais + "&contIdCards=" + fenpaiId + "&productSourceB=" + productSource;
            });
    }

    function toDetail(callLoanNid, userId, repaymentId) {
        console.log("callLoanNid:" + callLoanNid);
        window.location = "cuijimanage/toDescPage.do?callLoanNid="
            + callLoanNid + "&userId=" + userId + "&repaymentId=" + repaymentId;
    }

    //通过/拒绝
    function passBtn(status, value, contId, productSource) {
        console.log(contId + "========" + productSource);
        console.log("当前的状态=="+status);
        if(status=='1'){
        	layer.confirm(
                    '',
                    {
                        title: "黑名单审核当前操作确认  （通过）",
                        btn: ['确定','取消'], //可以无限个按钮
                        btnAlign: 'c'
                        , btn3: function (index, layero) {
                        layer.closeAll();
                    }
                    },
                    function (index, layero) {//审核通过
           			 window.location = "blackName/checkStatus.do?status=" + status + "&id=" + value + "&contIdCardB=" + contId + "&productSourceB=" + productSource;
                    });
        }else{
        	layer.confirm(
                    '',
                    {
                        title: "黑名单审核当前操作确认  （拒绝）",
                        btn: ['确定','取消'], //可以无限个按钮
                        btnAlign: 'c'
                        , btn3: function (index, layero) {
                        layer.closeAll();
                    }
                    },
                    function (index, layero) {//审核通过
           			 window.location = "blackName/checkStatus.do?status=" + status + "&id=" + value + "&contIdCardB=" + contId + "&productSourceB=" + productSource;
                    });
        }
        
        
    }

</script>

<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>
<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
<script type="text/javascript"
        src="static/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="static/js/bootbox.min.js"></script>
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript">
</script>
</body>
</html>